package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.CompanyService;
import com.yixun.qfbao.apidto.GetCompanyInfoReqDto;
import com.yixun.qfbao.apidto.GetCompanyInfoResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetCompanyInfoReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class GetCompanyInfoHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(GetCompanyInfoHander.class);

    @Autowired
    private CompanyService companyService;

    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        BaseResponseDTO<GetCompanyInfoResDto> res = new BaseResponseDTO<>();
        GetCompanyInfoReqVo reqVo = (GetCompanyInfoReqVo)reqDto;
        GetCompanyInfoReqDto getCompanyStatusInfoReqDto = reqVo.getParams();
        try {
            GetCompanyInfoResDto getCompanyInfoResDto = companyService.getCompanyInfo(getCompanyStatusInfoReqDto);
            res.setResData(getCompanyInfoResDto);
            res.setResult(getCompanyInfoResDto.getResult());
        } catch (Exception e) {
            logger.error("GetCompanyInfoHander error: {}", e);
            res.setResult(ResultEnum.FAIL.getNo());
            res.setErrorMsg("获取信息失败");
        }
        return res;
    }
}
